<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Update Function </title>
</head>

<body>
/**<br />
* <{$functionName}> ,<{$functionDescription}><br />
* <br />
* @param MySQLi $_dbObject  <br />
  <{foreach from=$updatedAttributes item=pa name=foo}>
* @param <{if $pa->singleQuotes=="'"}>string <{else}>int <{/if}><{$pa->updateParamName}><br />
  <{/foreach}>
  <{foreach from=$whereStrs item=pa name=foo}>
* @param <{if $pa->singleQuotes=="'"}>string <{else}>int <{/if}>$<{$pa->valueName}> <br />
  <{/foreach}>
* @param int $updateSelf , 1 set this object value to updated value after successfully update, 0 don't update this object <br />
* @return FALSE means error, other means the number of records which are affected<br />
 */<br />

 function <{$functionName}>(MySQLi $_dbObject
<{foreach from =$updatedAttributes item=ips name=foo}>
,
 <{$ips->updateParamName}>
<{/foreach}>
<{foreach from=$whereStrs item=pa name=foo}>
  ,$<{$pa->valueName}>
  <{/foreach}>
, $updateSelf=1){<br />

 
$whereStr=&quot; where 1=1 &quot;;<br />
  <br />
  <{foreach from=$whereStrs item=wStr name=foo}>
   if(isset($<{$wStr->valueName}>) <{if $wStr->singleQuotes=="'"}> &amp;&amp; $<{$wStr->valueName}>!=&quot;&quot;<{/if}>){<br />
$whereStr.=sprintf(&quot; and `<{$wStr->fieldName}>` <{$wStr->operator}> 
   <{$wStr->singleQuotes}><{$wStr->likeHeadStr}><{$wStr->sprintfStr}><{$wStr->likeTailStr}><{$wStr->singleQuotes}>&quot;,
   <{if $wStr->escapeStr==1}>$this-&gt;escape_string(<{/if}>$<{$wStr->valueName}><{if $wStr->escapeStr==1}>)<{/if}>);<br />
<br />
<br />}<br />
<br />
 <{/foreach}>
<br />

  
  $sqlhead=sprintf(&quot;update  &quot;.<{$tableObj->definedTableName}>.&quot;  <{$aliasName}> set 
  <{foreach from=$updatedAttributes item=att name=foo}>
  <{if $smarty.foreach.foo.index !=0 }>,<{/if}>`<{$att->Field}>`=<{$att->singleQuotes}><{$att->sprintfStr}><{$att->singleQuotes}>
  <{/foreach}>

  <{foreach from=$fixedVG item=att name=foo}>
  <{if $smarty.foreach.foo.index !=0 || count($updatedAttributes)>0 }>,<{/if}>
  `<{$att->Field}>`=<{$att->fixedValue}> 
  <{/foreach}>

  
  &quot;<br />
  <{foreach from =$updatedAttributes item=ips name=foo}>
  , <{if $ips->escapeStr==1}>$this-&gt;escape_string(<{/if}>
  <{$ips->updateParamName}>
  <{if $ips->escapeStr==1}>)<{/if}>
  
  <{/foreach}>
);<br />
<br />
  
$sql=$sqlhead.$whereStr;<br />
  //echo $sql.&quot;&lt;br //&gt;&quot;;<br />
  <br />
  <br />
  $_re=$_dbObject-&gt;query($sql);<br />

if($_re!=FALSE){<br />
<br />
if($updateSelf==1){<br />
<br />

  <{foreach from =$updatedAttributes item=ips name=foo}>
  <br />
  $this-&gt;<{$ips->attribute}>=<{$ips->updateParamName}>;

  <{/foreach}>
<br />
<br />}<br />
$re=$_dbObject-&gt;affected_rows;<br />
<br />
<br />
<br />}<br />
   
   else{<br />
<br />
$re=FALSE;
<br />
<br />}<br />
<br />
  return $re;<br />
<br />
<br />}<br />



<br />
<br /></body>
</html>
